
import json
import traceback

class SuccessResponse(object):
    def __init__(self, Code: int, Data: dict=None):
        self.Code = Code
        self.Data = Data
    
    def to_dict(self):
        return {
            'Code': self.Code,
            'Data': self.Data
        }
    
    def to_json(self):
        return json.dumps(self.to_dict())


class FailResponse(object):
    def __init__(self, Code: str, Message: str):
        self.Code = Code
        self.Message = Message
    
    def to_dict(self):
        return {
            'Code': self.Code,
            'Message': self.Message
        }

    def to_json(self):
        return json.dumps(self.to_dict())




# try:
#     a = 1/0

# except Exception as e:
#     #捕获异常的堆栈信息
#     error_stack_trace = traceback.format_exc() 
#     res = FailResponse(type(e).__name__, error_stack_trace)
